package com.atguigu.spzx.manager.service.Impl;

import com.atguigu.spzx.manager.mapper.SysUserRoleMapper;
import com.atguigu.spzx.manager.service.SysUserRoleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author LT
 * @create 2023-11-06-19:07
 */
@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {

    @Resource
    SysUserRoleMapper sysUserRoleMapper;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void assignRoles2User(Long userId, List<Long> roleIds) {
        sysUserRoleMapper.deleteRolesByUserId(userId);

        sysUserRoleMapper.assignRoles2User(userId,roleIds);
    }
}
